package http_proxy_middleware

import (
	"go_gateway/reverse_proxy"
	"go_gateway/reverse_proxy/load_balance"

	"github.com/gin-gonic/gin"
)

//匹配接入方式 基于请求信息
func HTTPReverseProxyMiddleware(lb load_balance.LoadBalance) gin.HandlerFunc {
	return func(c *gin.Context) {
		//middleware.ResponseSuccess(c,"ok")
		//return
		//创建 reverseproxy
		//使用 reverseproxy.ServerHTTP(c.Request,c.Response)
		proxy := reverse_proxy.NewLoadBalanceReverseProxy(c, lb)
		proxy.ServeHTTP(c.Writer, c.Request)
		c.Abort()
		return
	}
}
